# encoding=utf-8

import jieba


class ZhcnSeg:

    def __init__(self, stopwords: list):
        """
        :param stopwords: 停用词列表
        """
        self.stopwords = stopwords

    def cut(self, sentence, stop_word=True):
        seg_list = jieba.cut(sentence)

        results = []
        for seg in seg_list:
            if seg in self.stopwords and stop_word:
                continue
            results.append(seg)

        return results

    def cut_for_search(self, sentence, stop_word=True):
        seg_list = jieba.cut_for_search(sentence)

        results = []
        for seg in seg_list:
            if seg in self.stopwords and stop_word:
                continue
            results.append(seg)

        return results
